﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using RBS.Web.API.Models;

namespace RBS.Web.API.Areas.Hotel.Controllers
{
    /// <summary>
    /// 座位API
    /// </summary>
    public class SeatController : ApiController
    {
        private ApiContext db = new ApiContext(); 
        /// <summary>
        /// 获取酒店API
        /// </summary>
        /// <param name="hid">酒店ID</param>
        /// <param name="type">大厅,包间</param>
        /// <returns></returns>
       /* public JsonData Get(int hid,string type)
        { 
            var jsonData = new JsonData { Success = true }; 
            var clients = db.HotelSeat.Where(c => c.HotelId ==hid && c.Category==type);
            jsonData.Data = clients.OrderByDescending(c => c.Id).ToList();
            return jsonData;
        }*/
        /// <summary>
        /// 获取酒店可以餐桌
        /// </summary>
        /// <param name="hid"></param>
        /// <returns></returns>
        public JsonData Get(int id,string time)
        {
           var jsonData = new JsonData { Success = true };
            /* var clients = db.HotelSeat.Where(c => c.HotelId == id && c.AOBT==1 );
            jsonData.Data = clients.OrderByDescending(c => c.Category).ToList();
            return jsonData;*/ 

            var time1 = Convert.ToDateTime(time).AddHours(-3);
            var time2 = Convert.ToDateTime(time).AddHours(3);
            jsonData.Data = new RBS.Core.BLL.Hotel.H_Hotel_Seat().GetSeatList(id, time1, time2);
            return jsonData;
        }

        /// <summary>
        /// 修改座位状态
        /// </summary>
        /// <param name="id">座位ID</param>
        /// <param name="status">座位状态</param>
        public void UpdateSeatStatus(int id, int status)
        {
 
                var model = db.HotelSeat.Find(id);
                if (model == null)
                {
                    return;
                }
                model.Status = 1; 

            new BaseRepository<RBS.Core.Model.Hotel.H_Hotel_Seat>().UpdateEntities(model);
        }
    }
}
